
#ifndef __GPCOMPUTE_H__
#define __GPCOMPUTE_H__

#include "GPConfig.h"

// thread not safe, bacause D3D8 or ... may not safe !!
typedef struct _GpCompute*      HGPGPU;
typedef struct _GpComputeSub*	HGPGPUSUB;
typedef struct _GpArray*        HGPARRAY;
typedef struct _GpVrray*        HGPVRRAY;
typedef struct _GpShapeRect*    HGPSHAPERECT;

#ifdef __cplusplus
extern "C" {
#endif //

// init compute engine hanele 
int GpComputeInit( HGPGPU* hgpgpu, GP_CONTEXT const* ctx, GP_HINT hint /*=0*/ );
// clear 
int GpComputeFree( HGPGPU hgpgpu );
// can get some direct3d pointer : 
int GpComputePtrByHint( int hint, void* inptr, void **outptr );

// often 2048, 4096, dimID 0=X, 1=Y 
int GpComputeMaxDimSize( HGPGPU hgpgpu, int dimid );

// per dot unit 
int GpComputeAllocate( HGPGPU hgpgpu, long width, long height, GP_TYPE t, GP_INPUTPREC f, GP_OPMODE p, HGPARRAY* gparray );

int GpComputeDeallocate( HGPGPU hgpgpu, HGPARRAY hgparray ); // write-only!

int GpComputeGetPointer( HGPARRAY hgparray, void** pdata, long* pitch );

int GpComputeAllocateVram( HGPGPU hgpgpu, long width, long height, GP_TYPE t, GP_INPUTPREC f, GP_OPMODE p, HGPVRRAY* gpvrray );

int GpComputeDeallocateVram( HGPGPU hgpgpu, HGPVRRAY hgpvrray );

int GpComputeSubmit( HGPGPU hgpgpu, HGPARRAY hgparray, HGPVRRAY hgpvrray, long dstx, long dsty ); // submit to/from correspond texture

int GpComputeSubmitEx( HGPGPU hgpgpu, HGPARRAY hgparray, long xoff, long yoff, long xlen, long ylen, HGPVRRAY hgpvrray, long dstx, long dsty );

int GpComputeSelectSourceUnit( HGPGPU hgpgpu, HGPVRRAY hgpvrray, int index );

// shapes x,y rect z,w help, while help could default to 0, 1 values when NULL assigned !
int GpComputeShapeRect( HGPGPU hgpgpu, GP_RECT const* rects, int count, HGPSHAPERECT* vrect );

int GpComputeShapeRectEx( HGPGPU hgpgpu, GP_RECT const* rects, float const* depth, float const* div, int count, HGPSHAPERECT* vrect );

int GpComputeShapeRectT( HGPGPU hgpgpu, GP_RECT const* rects, GP_RECT const* trects, int count, HGPSHAPERECT* vrect );

int GpComputeShapeRectTEx( HGPGPU hgpgpu, GP_RECT const* rects, GP_RECT const* trects, float const* depth, float const* div, int count, HGPSHAPERECT* vrect );

int GpComputeShapeFree( HGPGPU hgpgpu, HGPSHAPERECT shape ); // 

int GpComputeSelectSourceShape( HGPGPU hgpgpu, HGPSHAPERECT shape );

// renders 
int GpComputeSetProp( HGPGPU hgpgpu, GP_CALCSTATE const* calcstate );

int GpComputeBeginTarget( HGPGPU hgpgpu, HGPVRRAY hgpvrray, GP_PREPARE const* prepare );
// [beginidx, endidx) using rect ( 4point )
int GpComputeCalculateRect( HGPGPU hgpgpu, int beginidx, int endidx, GP_RECT const* dst/*=NULL*/ );

int GpComputeEndTarget( HGPGPU hgpgpu, int present );

int GpComputePresentOut( HGPGPU hgpgpu );

int GpComputePresentOnCanvas( HGPGPU hgpgpu, void* canvas );

// shaders 
int GpComputeCreateProgram( HGPGPU hgpgpu, GP_PROGRAM t, unsigned long * progid, const void* buffer );

int GpComputeDeleteProgram( HGPGPU hgpgpu, GP_PROGRAM t, unsigned long progid );

int GpComputeSelectProgram( HGPGPU hgpgpu, GP_PROGRAM t, unsigned long progid );
// the buffer should consist alignment of [4 * sizeof(float)], the offset and count is counted by unit of [float4]
int GpComputeSetConstants( HGPGPU hgpgpu, GP_PROGRAM t, int offset, const void* buffer, int count );

#ifdef __cplusplus
}
#endif // 

#endif // __GPCOMPUTE_H__
